# -*- coding: utf-8 -*-

# pip install pillow
from PIL import Image, ImageFont, ImageDraw


def image_text():
    """图片上加文字"""
    image = Image.open("open.png")  # 打开图片
    image_draw = ImageDraw.Draw(image)
    fontsize = int(min(image.size) / 4)
    font = ImageFont.truetype(r"C:\Windows\Fonts\simhei.ttf", fontsize)

    image_draw.text((image.size[0] - fontsize, 0), "6", font=font, fill=(255, 0, 0))
    image.save("save.png")
    pass


if __name__ == '__main__':
    image_text()
    pass
